package com.example.steveaoblogdemo.controller;

import com.example.steveaoblogdemo.entity.Comment;
import com.example.steveaoblogdemo.service.impl.CommentServiceImpl;
import com.example.steveaoblogdemo.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@RestController
public class CommentController {
    @Resource
    CommentServiceImpl commentService;

    @PostMapping("/comment/addComment")
    public int addComment(@RequestParam(required = false) Integer id, @RequestParam(defaultValue = "0") Integer aId,
                          @RequestParam(defaultValue = "") String cName, @RequestParam(defaultValue = "") String content,
                          @RequestParam(defaultValue = "") String createTime, @RequestParam(required = false) Integer parentId,
                          @RequestParam(defaultValue = "")String reply){

        return commentService.addComment(id,aId,cName,content,createTime,parentId,reply);
    }
    @GetMapping("/comment/getComment")
    public Result<?> getComment(@RequestParam(defaultValue = "0")Integer aId){
        return commentService.getCommentList(aId);
    }

    @PutMapping("/comment/deleteComment")
    public Result<?> deleteComment(@RequestParam(required = false)Integer id){
        return commentService.deleteComment(id);
    }
}
